package com.jsfcomponent.domain;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Entity
public class Bee implements Serializable {
	@Id
	private int id;
	private String name;
	
	@ManyToOne
	private Honey honey;

	private static final long serialVersionUID = 1L;

	public Bee() {
		super();
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Honey getHoney() {
		return this.honey;
	}

	public void setHoney(Honey honey) {
		this.honey = honey;
	}

	
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Bee)){
			return false;
		}
		Bee other=(Bee) obj;
		return id==other.getId() && other.getName().equals(getName());
	}
	
	@Override
	public int hashCode() {	
		return id+((name!=null)?name.hashCode():super.hashCode());
	}
}
